﻿using System;
using System.Data;
using System.Configuration;
using System.Data.OleDb;

namespace JSClass
{
    /// <summary>
    /// JSExecuteQuery의 요약 설명입니다.
    /// </summary>
    public class ExecuteQuery
    {
        /** 
	     * 오라클 연결 객체
	     */
        private OleDbConnection conn = null;
        private OleDbCommand cmd = null;

        public ExecuteQuery()
        {
            this.openDB();

            cmd = new OleDbCommand();
            cmd.Connection = conn;
        }

        public void executeQuery(String query)
        {
            try
            {
                cmd.CommandText = query;
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
            finally
            {
                this.closeDB();
            }
        }

        public void executeQueryOne(String query)
        {
            try
            {
                cmd.CommandText = query;
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }

        /**
		* 오라클 연결을 생성한다.
		* @return 오라클 연결 객체
		*/
        private void openDB()
        {
            conn = new OleDbConnection(ConfigurationSettings.AppSettings["ex_db"]);
            conn.Open();
        }

        /**
        * 오라클 연결을 닫는다.
        * @return 오라클 연결 객체
        */
        public void closeDB()
        {
            conn.Close();
        }
    }
}
